/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Database;

import Model.UserPenerima;
import java.util.ArrayList;
import javax.swing.table.AbstractTableModel;

public class UserPenerimaTable extends AbstractTableModel {

    private String columns[] = {"ID User", "Nama User"};
    private ArrayList<UserPenerima> datapenerima;

    public UserPenerimaTable() {
    }

    public UserPenerimaTable(ArrayList<UserPenerima> datapenerima) {
        this.datapenerima = datapenerima;
    }

    @Override
    public int getRowCount() {
        return getDataPenerima().size();
    }

    public String getColumns(int col) {
        return columns[col];
    }

    @Override
    public int getColumnCount() {
        return columns.length;
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        UserPenerima penerima = getDataPenerima().get(rowIndex);
        if (columnIndex == 0) {
            return penerima.getIdUserPenerima();
        } else {
            return penerima.getNamaUserPenerima();
        }
    }

    public ArrayList<UserPenerima> getDataPenerima() {
        return datapenerima;
    }

    public void setDataPenerima(ArrayList<UserPenerima> datapenerima) {
        this.datapenerima = datapenerima;
    }
}
